export const dealDayList  = (stockData, days) => {
    // 辅助函数：获取极值及其时间
    const getExtremes = (values, times) => {
      const max = Math.max(...values);
      const min = Math.min(...values);
      return {
        max: { value: max, time: times[values.indexOf(max)] },
        min: { value: min, time: times[values.indexOf(min)] }
      };
    };
    // 当前周期数据
    const currentValues = stockData.array.slice(-days);
    const currentTimes = stockData.time.slice(-days);
    const current = getExtremes(currentValues, currentTimes);
    // 上一个周期数据
    const prevStart = -days * 2;
    const previousValues = stockData.array.slice(prevStart, -days);
    const previousTimes = stockData.time.slice(prevStart, -days);
    const previous = getExtremes(previousValues, previousTimes);
     // 上上一个周期数据
     const prevStart2 = -days * 3;
     const previousValues2 = stockData.array.slice(prevStart2, -days*2);
     const previousTimes2 = stockData.time.slice(prevStart2, -days*2);
     const previous2 = getExtremes(previousValues2, previousTimes2);
    // 信息结构模板
    const INFO_LABELS = [
      { type: 'max', label: '最大涨幅' },
      { type: 'min', label: '最大跌幅' }
    ];
    // 构建结果数组
    return [
      ...INFO_LABELS.map(({ type, label }) => ({
        name: `${days}天内${label}`,
        num: current[type].value.toFixed(2),
        time: current[type].time
      })),
      ...INFO_LABELS.map(({ type, label }) => ({
        name: `上一个${days}天内${label}`,
        num: previous[type].value.toFixed(2),
        time: previous[type].time
      })),
      ...INFO_LABELS.map(({ type, label }) => ({
        name: `再上一个${days}天内${label}`,
        num: previous2[type].value.toFixed(2),
        time: previous2[type].time
      }))
    ];
  };

  export default {
    dealDayList
  
  }
  